/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Vistas;

import com.toedter.calendar.JDateChooser;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.awt.event.KeyListener;
import java.text.SimpleDateFormat;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.JTextField;


public class VViaje extends javax.swing.JFrame {

    /**
     * Creates new form VViaje2
     */
    public VViaje() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        dchFechaSalida = new com.toedter.calendar.JDateChooser();
        dchFechaLlegada = new com.toedter.calendar.JDateChooser();
        cmbTipoDestino = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        cmbDestino = new javax.swing.JComboBox();
        btnGenerarVehiculo = new javax.swing.JButton();
        btnGenerarChofer = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblViajes = new javax.swing.JTable();
        btnSalir = new javax.swing.JButton();
        btnGuardar = new javax.swing.JButton();
        btnActualizar = new javax.swing.JButton();
        btnEliminar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtVehiculi = new javax.swing.JTextField();
        txtChofer = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        cmbHoraSalida = new javax.swing.JComboBox();
        txtHoraRetorno = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("VIAJE");
        setUndecorated(true);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
        jLabel1.setText("VIAJE");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 10, -1, -1));

        jLabel2.setText("Fecha de salida:");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 60, -1, -1));

        jLabel3.setText("Fecha de llegada:");
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 60, -1, -1));

        jLabel4.setText("Tipo de destino:");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 60, -1, -1));
        getContentPane().add(dchFechaSalida, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 60, 100, -1));
        getContentPane().add(dchFechaLlegada, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 60, 100, -1));

        cmbTipoDestino.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbTipoDestino.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cmbTipoDestinoItemStateChanged(evt);
            }
        });
        cmbTipoDestino.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cmbTipoDestinoKeyPressed(evt);
            }
        });
        getContentPane().add(cmbTipoDestino, new org.netbeans.lib.awtextra.AbsoluteConstraints(710, 60, -1, -1));

        jLabel7.setText("Destino:");
        getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(640, 120, -1, -1));

        cmbDestino.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        getContentPane().add(cmbDestino, new org.netbeans.lib.awtextra.AbsoluteConstraints(710, 120, -1, -1));

        btnGenerarVehiculo.setText("Seleccionar Vehiculo");
        getContentPane().add(btnGenerarVehiculo, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 120, -1, -1));

        btnGenerarChofer.setText("Seleccionar Chofer");
        getContentPane().add(btnGenerarChofer, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 120, 170, -1));

        tblViajes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "Placa", "Destino", "Fecha Salida", "Hora Salida", "Fecha Regreso", "Hora Regreso", "Chofer", "Seguro", "Impuesto"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tblViajes);

        getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 190, 790, 310));

        btnSalir.setText("Salir");
        getContentPane().add(btnSalir, new org.netbeans.lib.awtextra.AbsoluteConstraints(840, 350, 100, -1));

        btnGuardar.setText("Guardar");
        getContentPane().add(btnGuardar, new org.netbeans.lib.awtextra.AbsoluteConstraints(840, 190, 100, -1));

        btnActualizar.setText("Actualizar");
        getContentPane().add(btnActualizar, new org.netbeans.lib.awtextra.AbsoluteConstraints(840, 230, 100, -1));

        btnEliminar.setText("Eliminar");
        btnEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarActionPerformed(evt);
            }
        });
        getContentPane().add(btnEliminar, new org.netbeans.lib.awtextra.AbsoluteConstraints(840, 270, 100, -1));

        btnCancelar.setText("Cancelar");
        getContentPane().add(btnCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(840, 310, 100, -1));

        jLabel5.setText("Vehiculo Seleccionado:");
        getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 160, -1, -1));

        jLabel6.setText("Chofer Seleccionado:");
        getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 160, -1, -1));

        txtVehiculi.setEditable(false);
        getContentPane().add(txtVehiculi, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 160, 130, -1));

        txtChofer.setEditable(false);
        getContentPane().add(txtChofer, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 160, 120, -1));

        jLabel8.setText("Hora de Salida:");
        getContentPane().add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 90, -1, -1));

        jLabel9.setText("Hora estimada de retorno:");
        getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 90, -1, -1));

        cmbHoraSalida.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione" }));
        getContentPane().add(cmbHoraSalida, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 90, -1, -1));

        txtHoraRetorno.setEditable(false);
        getContentPane().add(txtHoraRetorno, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 90, 90, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnEliminarActionPerformed

    private void cmbTipoDestinoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbTipoDestinoKeyPressed
        // TODO add your handling code here:
      
    }//GEN-LAST:event_cmbTipoDestinoKeyPressed

    private void cmbTipoDestinoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmbTipoDestinoItemStateChanged
        // TODO add your handling code here:
      
    }//GEN-LAST:event_cmbTipoDestinoItemStateChanged

    
    
    public JButton getBtnActualizar() {
        return btnActualizar;
    }

    public void setBtnActualizar(JButton btnActualizar) {
        this.btnActualizar = btnActualizar;
    }

    public JButton getBtnCancelar() {
        return btnCancelar;
    }

    public void setBtnCancelar(JButton btnCancelar) {
        this.btnCancelar = btnCancelar;
    }

    public JButton getBtnEliminar() {
        return btnEliminar;
    }

    public void setBtnEliminar(JButton btnEliminar) {
        this.btnEliminar = btnEliminar;
    }

    public JButton getBtnGenerarChofer() {
        return btnGenerarChofer;
    }

    public void setBtnGenerarChofer(JButton btnGenerarChofer) {
        this.btnGenerarChofer = btnGenerarChofer;
    }

    public JButton getBtnGenerarVehiculo() {
        return btnGenerarVehiculo;
    }

    public void setBtnGenerarVehiculo(JButton btnGenerarVehiculo) {
        this.btnGenerarVehiculo = btnGenerarVehiculo;
    }

    public JButton getBtnGuardar() {
        return btnGuardar;
    }

    public void setBtnGuardar(JButton btnGuardar) {
        this.btnGuardar = btnGuardar;
    }

    public JButton getBtnSalir() {
        return btnSalir;
    }

    public void setBtnSalir(JButton btnSalir) {
        this.btnSalir = btnSalir;
    }

    public JComboBox getCmbDestino() {
        return cmbDestino;
    }

    public void setCmbDestino(JComboBox cmbDestino) {
        this.cmbDestino = cmbDestino;
    }

    public JComboBox getCmbTipoDestino() {
        return cmbTipoDestino;
    }

    public void setCmbTipoDestino(JComboBox cmbTipoDestino) {
        this.cmbTipoDestino = cmbTipoDestino;
    }

    public JDateChooser getDchFechaLlegada() {
        return dchFechaLlegada;
    }

    public void setDchFechaLlegada(JDateChooser dchFechaLlegada) {
        this.dchFechaLlegada = dchFechaLlegada;
    }

    public JDateChooser getDchFechaSalida() {
        return dchFechaSalida;
    }

    public void setDchFechaSalida(JDateChooser dchFechaSalida) {
        this.dchFechaSalida = dchFechaSalida;
    }

    public JTable getTblViajes() {
        return tblViajes;
    }

    public void setTblViajes(JTable tblViajes) {
        this.tblViajes = tblViajes;
    }

    public JTextField getTxtChofer() {
        return txtChofer;
    }

    public void setTxtChofer(JTextField txtChofer) {
        this.txtChofer = txtChofer;
    }

    public JTextField getTxtVehiculi() {
        return txtVehiculi;
    }

    public void setTxtVehiculi(JTextField txtVehiculi) {
        this.txtVehiculi = txtVehiculi;
    }
    
    public void mostrarMensaje(String mensaje)
    {
        JOptionPane.showMessageDialog(this, mensaje);
    }

     public String fechaSalida(){
        SimpleDateFormat formateador = new SimpleDateFormat("dd-MM-yyyy");
        String stringFecha = formateador.format(dchFechaSalida.getDate());
       return stringFecha;
    }
          public String fechaLlegada(){
        SimpleDateFormat formateador = new SimpleDateFormat("dd-MM-yyyy");
        String stringFecha = formateador.format(dchFechaLlegada.getDate());
       return stringFecha;
    }

    public JComboBox getCmbHoraSalida() {
        return cmbHoraSalida;
    }

    public void setCmbHoraSalida(JComboBox cmbHoraSalida) {
        this.cmbHoraSalida = cmbHoraSalida;
    }

    public JTextField getTxtHoraRetorno() {
        return txtHoraRetorno;
    }

    public void setTxtHoraRetorno(JTextField txtHoraRetorno) {
        this.txtHoraRetorno = txtHoraRetorno;
    }
    public void agregarItemListerner(ItemListener accionListener)
    {
        cmbTipoDestino.addItemListener(accionListener);
        cmbHoraSalida.addItemListener(accionListener);
    }

    
    public void agregarListener(ActionListener accion)
    {
        btnActualizar.addActionListener(accion);
        btnCancelar.addActionListener(accion);
        btnEliminar.addActionListener(accion);
        btnGenerarChofer.addActionListener(accion);
        btnGenerarVehiculo.addActionListener(accion);
        btnGuardar.addActionListener(accion);
        btnSalir.addActionListener(accion);
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnActualizar;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnEliminar;
    private javax.swing.JButton btnGenerarChofer;
    private javax.swing.JButton btnGenerarVehiculo;
    private javax.swing.JButton btnGuardar;
    private javax.swing.JButton btnSalir;
    private javax.swing.JComboBox cmbDestino;
    private javax.swing.JComboBox cmbHoraSalida;
    private javax.swing.JComboBox cmbTipoDestino;
    private com.toedter.calendar.JDateChooser dchFechaLlegada;
    private com.toedter.calendar.JDateChooser dchFechaSalida;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tblViajes;
    private javax.swing.JTextField txtChofer;
    private javax.swing.JTextField txtHoraRetorno;
    private javax.swing.JTextField txtVehiculi;
    // End of variables declaration//GEN-END:variables
}
